<?php
/**
 * Created by @baidu-aip
 * Author: ylang
 * Time: 2022/2/24 12:06
 */

namespace Hedgehog\BaiduAip;

use Hanson\Foundation\Foundation;
use Hedgehog\BaiduAip\Api\ImageClassify;
use Hedgehog\BaiduAip\Api\Orc;
use Hedgehog\BaiduAip\Exception\InvalidConfigException;


/**
 * @property Orc           $orc
 * @property ImageClassify $image_classify
 */
class BaiduAip extends Foundation
{

    protected $providers = [
        ServiceProvider::class
    ];


    public function getAppConfig(?string $name = null)
    {
        $name = $name ?: $this->getConfig('use');
        $apps = $this->getConfig('apps');

        return $apps[$name] ?? InvalidConfigException::error("invalid app: {$name}");
    }


    public function use(string $name)
    {
        $config = $this->getConfig();
        $config['use'] = $name;

        $this->setConfig($config);
        return $this;
    }


}